package com.itwill.ecom.category;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository("categoryService")
public class CategoryServiceImpl implements CategoryService{
	//// CategoryBeans 객체 생성 ////
	@Autowired
	CategoryDao categoryDao;

	public CategoryServiceImpl() {
		System.out.println("categoryService 생성");
	}


	public CategoryServiceImpl(CategoryDao categoryDao) {
		
		this.categoryDao = categoryDao;
	}
	

	public CategoryDao getCategoryDao() {
		return categoryDao;
	}


	public void setCategoryDao(CategoryDao categoryDao) {
		this.categoryDao = categoryDao;
	}


	//// 카테고리 생성 ////
	@Override
	public int createCategory(CategoryBeans categoryBeans) {
	
		int result=-1;
		try{
			result=categoryDao.createCategory(categoryBeans);
			result=1;
			
		}catch(Exception e){
			e.printStackTrace();
			System.out.println("오류내역:"+e.getMessage());
			
		}
		return result;
	}
	
	//// 카테고리 리스트 ////
	@Override
	public CategoryBeans getCategory(int category_no) {
		CategoryBeans list=null;
		try{
			list=categoryDao.getCategory(category_no);
		}catch(Exception e){
			e.printStackTrace();
			e.getMessage();
		}
		
		return list;
	}
	
	//// 카테고리 전체 리스트 ////
	@Override
	public List<CategoryBeans> getCategoryAll() {
		List<CategoryBeans> list=null;
		try{
			list=categoryDao.getAllCategory();
		}catch(Exception e){
			e.printStackTrace();
			e.getMessage();
		}
		
		return list;
	}
	
	//// 카테고리 수정 ////
	@Override
	public int updateCategory(CategoryBeans categoryBeans) {
		int result=-1;
		try{
			result=categoryDao.updateCategory(categoryBeans);
			result=1;
		}catch(Exception e){
			e.getMessage();
		}
		return result;
	}
	//// 카테고리 삭제 ////
	@Override
	public int deleteCategory(int category_no) {
		int result=-1;
		try{
			result=categoryDao.deleteCategory(category_no);
			result=1;
		}catch(Exception e){
			e.getMessage();
		}
		return result;
	}

}
